<%= render 'menu/caidauadmin'%>

<table>
	<tr>
		<td>
				<table class="vienxanh">
					<tr>
					<th>Title</th>
					<th>Sender</th>
					<th>Date</th>
					<th>Status</th>
					<th>View Details</th>
					</tr>
					<% @allmess.each do |m| %>
					<tr>
						<td><%= m.Title%></td>
						<td><%= User.find_by_id(m.Uid).Username%></td>
						<td><%= m.Date_sent.strftime("%d-%m-%Y")%></td>
						<td>
							
							<% if m.Type==0%>
								Not Reply yet
							<% else%>
							    Replied
							<% end%>    	
							
						</td>
						<td><%= link_to 'View Details', :action=>'message_detailsbe', :mes=>m.id %></td>
					</tr>	
					
					<%end%>
										
				</table>	
		</td>
		<td>
				<%if !session[:mesdetail].nil?%>
				<fieldset align="left">
					<legend><h2><%= @detail.Title%></h2></legend>
					<%= form_tag :action => "reply" do%>
					<b>Sender:</b> <%= User.find_by_id(@detail.Uid).Username%> <br/>
					<b>Date:</b> <%= @detail.Date_sent.strftime("%d-%m-%Y")%> <br />
					<b>Content:</b> <br/>
					<textarea><%= @detail.Content%></textarea> <br />
					<b>Reply: </b><br/>
					<%= text_area_tag 'repmess','',{:rows=>4, :cols=>50} %>
					<br/>
					<%= submit_tag 'Reply'%>
					<% end %>
				</fieldset>	
					
				<%end%>
		</td>
			
	</tr>
	
	
</table>	
	
